#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int* solve(int* s, int n, int m) {
    /*********Begin*********/
    static int a[110];
    int i = 0, count, temp;
    for (count = 0; count < n; count++)
    {
        temp = i + n - m;
        while (temp > n - 1)
            temp -= n;
        a[count] = *(s + temp);
        i++;
    }
    return a;

    /*********End**********/
}
int main(void)
{
    int n, m, s[110];
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", &s[i]);
    int* ans;
    /*********Begin*********/
    ans = solve(s, n, m);
    /*********End**********/
    for (int i = 0; i < n; i++) {
        if (i == 0)    printf("%d", *ans++);
        else    printf(" %d", *ans++);
    }
    return 0;
}